home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************
- "cursor.c"
-
- by John A. Love, III [ Washington Apple Pi Users' Group]
-
- using Symantec's "THINK C", v 5.00
- *********************************************************/
-
-
- #include <Retrace.h>
-
- #include "protos"
-
- #include "globals.h"
- #include "extern.h"
-
- #include "floatingWindow.h"
-
-
-
-
- // Local prototype:
- pascal void SpinTheBottle (void); /* Cute, huh ?!!? */
-
-
- Boolean InWindow;
- Handle acurHdl;
- MyVBLType myVBLRec;
- short nbrGlobe;
- extern DialogPtr helpPtr;
- extern WindowPeek frontToolWindow, frontDocWindow;
-
-
-
-
- /* -----------------------
- ** Guess what this does ??
- ** ----------------------- */
-
- void HandleCursor (void) {
-
- GrafPtr savePort;
- Point mouse;
- CursHandle CURS;
- static CCrsrHandle niftyColorCRSR = nil;
- Boolean inFloatingWindow = false;
-
-
- /* DAs & other applications roll their own: */
- if (gCurrDA || !gInForeGround) return;
-
- if (gFW == nil) {
- InitCursor();
- if (niftyColorCRSR) {
- DisposCCursor(niftyColorCRSR);
- niftyColorCRSR = nil;
- }
- return;
- }
-
- if (frontToolWindow) {
- GetPort(&savePort);
- SetPort((WindowPtr) frontToolWindow);
- ;
- GetMouse(&mouse);
- if ( PtInRgn(mouse, ((WindowPtr)frontToolWindow)->visRgn) )
- inFloatingWindow = true;
- ;
- SetPort(savePort);
- }
-
- if (inFloatingWindow) {
-
- if (!gMac2) {
- CURS = GetCursor(FLOAT);
- if (CURS) SetCursor(*CURS);
- else InitCursor();
- }
-
- else if (niftyColorCRSR == nil) {
- niftyColorCRSR = GetCCursor(FLOAT);
- if (niftyColorCRSR) SetCCursor(niftyColorCRSR);
- else {
- CURS = GetCursor(FLOAT);
- if (CURS) SetCursor(*CURS);
- else InitCursor();
- }
- } /* end: gMac2 and NO color CRSR */
-
- }
-
- else /* NOT in Floating Window */ {
-
- if (niftyColorCRSR) {
- DisposCCursor(niftyColorCRSR);
- niftyColorCRSR = nil;
- }
-
- if (frontDocWindow) {
-
- GetMouse(&mouse);
- if ( PtInRgn(mouse, ((WindowPtr)frontDocWindow)->visRgn) ) {
-
- if (helpPtr == (WindowPtr)frontDocWindow) InitCursor();
- else { // NOT Pillera's Help Window.
-
- InitCursor();
-
-
- } /* NOT Pillera's Help Window */
-
- }
- else /* !PtInRgn() */ InitCursor();
-
- }
- else /* NO frontDocWindow */ InitCursor();
-
- } /* NOT in Floating Window */
-
- } /* HandleCursor */
-
-
-
- /* =============================
- ** Round-and-around she goes ...
- ** ============================= */
-
- void InstallVBLTask (short rsrcID) {
-
- CursHandle watch;
- short ignore;
-
-
- acurHdl = GetResource('acur', rsrcID);
- if (acurHdl == nil)
- {
- watch = GetCursor(watchCursor);
- SetCursor(*watch); /* Reset afterwards by my HandleCursor proc. */
- } /* acurHdl = nil */
- else
- {
- nbrGlobe = (*((acurHandle)acurHdl))->nbrCursors;
- ;
- myVBLRec.CurrA5 = (long)CurrentA5;
- myVBLRec.MyVBL.vblAddr = (ProcPtr)&SpinTheBottle;
- myVBLRec.MyVBL.vblCount = 10; /* Six times every second. */
- myVBLRec.MyVBL.qType = vType;
- myVBLRec.MyVBL.vblPhase = 0;
- ;
- ignore = VInstall( (QElemPtr)&(myVBLRec.MyVBL) );
-
- } /* else */
-
- } /* InstallVBLTask */
-
-
-
- void RemoveVBLTask (void) {
-
- short ignore;
- extern long Sleep;
-
-
- if (acurHdl != nil) ignore = VRemove( (QElemPtr)&myVBLRec.MyVBL );
- acurHdl = nil; /* Mark as gone. */
-
- /* CURSor reset later by "HandleCursor". */
- Sleep = 1; /* ... so this happens under Multifinder. */
-
- } /* RemoveVBLTask */
-
-
-
- /* =======================
- ** My spinning CURSor Task
- ** ======================= */
-
- pascal void SpinTheBottle (void) { /* Cute, huh ?!!? */
-
- CursHandle globe;
- short globeID;
-
-
- asm { // PushA5()
- move.l a5, -(sp)
- }
-
- asm { // GetMyA5()
- // Access my Globals by fetching the value of A5 we've stored
- // before the VBLTask and then put it into A5.
- //
- // We know that when the VBL task is called, A0 will point to it.
- // Therefore, the value of A5 that we stored will be at - 4(A0),
- // which is immediately below the VBL Task in our data block.
- move.l -4(a0), a5
- }
-
- globeID = HiWord( ( **((acurHandle)acurHdl) ).cursorIDs[nbrGlobe - 1] );
- globe = GetCursor(globeID);
- if (globe != nil) SetCursor(*globe);
-
- nbrGlobe = nbrGlobe - 1; /* Reset stuff for next time ... */
- if (nbrGlobe == 0) nbrGlobe = (*(acurHandle)acurHdl)->nbrCursors;
- ;
- myVBLRec.MyVBL.vblCount = 10;
-
- asm { // PopA5()
- move.l (sp)+, a5
- }
-
- } /* SpinTheBottle */
-
-
-
-
- /* { end file "cursor.c" } */
-